package com.day.controller;

import com.day.mapper.DormitoryMapper;
import com.day.pojo.Dormitory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/dormitory")
public class DormitoryController {
    @Autowired
    DormitoryMapper dormitoryMapper;
    @RequestMapping("/getDormitoryList")
    public List<Dormitory> getDormitoryList() {
        return dormitoryMapper.getDormitoryList();
    }
    @RequestMapping("getDormitoryById")
    public String getDormitory(Integer d_id){
        dormitoryMapper.getDormitoryById(d_id);
        return "查询单个宿舍";
    }
    @RequestMapping("/addDormitory")
    public String addDormitory(Dormitory dormitory) {
        dormitoryMapper.addDormitory(dormitory);
        return "添加宿舍成功";
    }
    @RequestMapping("/delDormitoryById")
    public String deleteDormitory(Integer d_id){
        dormitoryMapper.delDormitoryById(d_id);
        return "删除宿舍成功";
    }
    @RequestMapping("/editDormitoryById")
    public String editDormitory(Dormitory dormitory){
        dormitoryMapper.editDormitoryById(dormitory);
        return "修过宿舍成功";
    }
}
